package com.haidao.admin.component.web.utils;

import com.haidao.admin.component.entity.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.subject.Subject;

public class UserUtils {

    /**
     * 获取当前登录用户
     *
     * @return
     */
    public static User getCurrUser() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            User user = (User) subject.getPrincipal();
            if (user != null) {
                return user;
            }
        }
        throw new AuthenticationException("");
    }

}